﻿package component.formula.operation;

import component.formula.exception.FormulaException;


public class OperationFactory {
	
	public static Operation getOperation(String operator) throws FormulaException{
		if("+".equals(operator)){
			return new Add();
		}else if("-".equals(operator)){
			return new Subtract();
		}else if("*".equals(operator)){
			return new Multiply();
		}else if("/".equals(operator)){
			return new Divide();
		}else if("=".equals(operator) || "==".equals(operator)){
			return new Equal();
		}else if("!=".equals(operator)){
			return new NotEqual();
		}else if(">".equals(operator)){
			return new Greater();
		}else if(">=".equals(operator)){
			return new GreaterEqual();
		}else if("<".equals(operator)){
			return new Less();
		}else if("<=".equals(operator)){
			return new LessEqual();
		}else if("&".equals(operator) || "&&".equals(operator)){
			return new And();
		}else if("|".equals(operator) || "||".equals(operator)){
			return new Or();
		}else{
			throw new FormulaException(operator + " 操作符号不存在");
		}
	}
}
